<template>
  <div>
    <div>
      <h1>{{ this.topName }}</h1>
    </div>
    <div id="box">

      <el-row>
        <el-col :md="4" v-for="top in topData" :key="top.index">
          <div id="top">
            <img id="img" :src="top.coverImgUrl" @click="toSongList(top.id)">
            <p>{{top.updateFrequency}}</p>
          </div>
        </el-col>
      </el-row>

    </div>
  </div>
</template>

<script>
  import songs from "@/musicApi/apis/songs";
  export default {
    name: "topList",
    data() {
      return {
        topData: [],
        topName: '',
      }
    },
    mounted() {
      songs.getTopList().then(res => {
        this.topName = res.data.artistToplist.name
        this.topData = res.data.list
      })
    },
    methods: {
      //获取排行榜中的id，然后跳转歌单介绍
      toSongList(id) {
        this.$router.push({ path: '/songList', query: { id: id } });
      }
    }
  }
</script>

<style scoped>
  #img {
    width: 90%;
    margin-top: 20px;
    cursor: pointer;
  }

  #top {
    position: relative;
  }

  #top p {
    position: absolute;
    left: 10px;
    top: 10px;
    color: #ffcc00;
  }
</style>